//
//  ContentViewController.m
//  ShangChengMoBan
//
//  Created by yaoqi yaoqi on 16/8/31.
//  Copyright © 2016年 ping. All rights reserved.
//

#import "ContentViewController.h"
#import "DingDanRowTableViewCell.h"
#import "TuiKuanViewController.h"
#import "FaBiaoViewController.h"
#import "DD_shopModel.h"
@interface ContentViewController ()<UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate>

@property (weak, nonatomic) IBOutlet UILabel *yunfei;//运费
@property (weak, nonatomic) IBOutlet UILabel *hongBao;//红包优惠
@property (weak, nonatomic) IBOutlet UILabel *zongJia;//总支付价格
@property (weak, nonatomic) IBOutlet UILabel *youHui;//商家优惠
@property (weak, nonatomic) IBOutlet UILabel *bianHao;//订单编号
@property (weak, nonatomic) IBOutlet UILabel *time;//创建时间

@property (weak, nonatomic) IBOutlet UILabel *style;//交易状态
@property (weak, nonatomic) IBOutlet UILabel *lastTime;//剩余时间确认收货
@property (weak, nonatomic) IBOutlet UILabel *name;//收货人
@property (weak, nonatomic) IBOutlet UILabel *diZhi;//地址
@property (weak, nonatomic) IBOutlet UIImageView *TitleImage;//头部图片
@property (weak, nonatomic) IBOutlet UILabel *dianHua;
- (IBAction)callMaiJia:(id)sender;
- (IBAction)call:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *lastView;




@end

@implementation ContentViewController
{
     UIView * _bigView;
    UIView * _tanKuang,*_view,* _tanKuang2;
    UITextField * _inputTextField;
    UIView * _viewFang;
    UIView * footView;
    UIButton * button1,* button2,* button3;
    UITextView * _textView;
    float prize;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    prize = 0.0;
    [self drawNavWithTitle:@"订单详情" WithColor:[UIColor colorWithHue:0.00 saturation:0.00 brightness:1.00 alpha:1.00]];
    [self drawBackButton];
    UIView * headerView =[[[NSBundle mainBundle]loadNibNamed:@"DingDanContent" owner:self options:nil] lastObject];
   footView = [[[NSBundle mainBundle]loadNibNamed:@"DingDanFootView" owner:self options:nil] lastObject];
    
    UITableView * _table = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, KScreenWidth, KScreenHeight-64) style:UITableViewStyleGrouped];
    _table.delegate = self;
    _table.dataSource = self;
    _table.separatorStyle = UITableViewCellSelectionStyleNone;
    [_table registerClass:[DingDanRowTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:_table];
    _table.tableHeaderView = headerView;
    int num1 = [_allModel.payStatus intValue];
    int num2 = [_allModel.shippingStatus intValue];
    int num3 = [_allModel.orderStatus intValue];
    if (num3 == 2) {
        _style.text=@"订单已取消";
        _lastTime.text = @"";
        _TitleImage.image = [UIImage imageNamed:@"待付款"];
    }else{
        if (num1 == 0) {
            _style.text = @"等待买家付款";
            _lastTime.text = @"剩余10天2小时自动关闭";
            _TitleImage.image = [UIImage imageNamed:@"待付款"];
        }else if(num1 ==2)
        {

    switch (num2) {
        case 0:
            _style.text = @"买家已付款";
            _lastTime.text = @"";
            _TitleImage.image = [UIImage imageNamed:@"待发货"];
            break;
        case 1:
            _style.text = @"卖家已发货";
            _lastTime.text = @"还剩4天18时自动确认收货";
            _TitleImage.image = [UIImage imageNamed:@"待收货"];

            break;
        case 2:
            _style.text = @"交易成功";
            _lastTime.text = @"";
            _TitleImage.image = [UIImage imageNamed:@"待评论"];

            break;
        default:
            break;
    }
        }
    }
    [_allModel.OrderGoods enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        DD_shopModel * shopModel = obj;
        prize += ([shopModel.goodsPrice floatValue]+[shopModel.attr_price floatValue])*[shopModel.goodsNumber floatValue];
    }];
//    _yunfei.text = [NSString stringWithFormat:@"¥%@",];//运费
//    _hongBao.text = [NSString stringWithFormat:@"¥%@",];//红包优惠
    _zongJia.text = [NSString stringWithFormat:@"¥%.2f",prize];//总支付价
//    _youHui.text = [NSString stringWithFormat:@"¥%@",];//商家优惠
//    _bianHao.text = ;//商品编号
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:[_allModel.addTime intValue]];
    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
    _time.text = confromTimespStr;//时间
    _name.text = _allModel.consignee;//收货人名字
    _diZhi.text =[NSString stringWithFormat:@"%@%@%@%@",_allModel.province,_allModel.city,_allModel.district,_allModel.address]; ;//收货人地址
    _dianHua.text = _allModel.mobile;//收货人电话
    [self drawYuEView];
    [self drawYuEView2];
    [self zhiFuFangShi];
 }

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _allModel.OrderGoods.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    DingDanRowTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.backgroundColor = [UIColor colorWithHue:0.00 saturation:0.00 brightness:0.92 alpha:1.00];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    DD_shopModel * shopModel = _allModel.OrderGoods[indexPath.row];
    NSMutableAttributedString *  attribtStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"¥%.2f",[shopModel.marketPrice floatValue]+[shopModel.attr_price floatValue]] ];
    [attribtStr addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, attribtStr.length)];
    cell.zheKou.attributedText = attribtStr;  //商品原价
    cell.title.text = shopModel.goodsName;    //商品名称
    [cell.image sd_setImageWithURL:[NSURL URLWithString:shopModel.goodsImg]];  //商品图片

    cell.prize.text = [NSString stringWithFormat:@"¥%.2f",[shopModel.goodsPrice floatValue]+[shopModel.attr_price floatValue]] ;   //商品售价
    cell.num.text = [NSString stringWithFormat:@"X%@",shopModel.goodsNumber];//商品数量
    NSString * a = shopModel.goodsAttr;
    cell.size.text = a;
    if (![a isEqualToString:@""]) {
        cell.size.text = [a substringWithRange:NSMakeRange(0, a.length-1)];   //商品属性
    }
        return cell;
  }
-(UIView * )tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    int num1 = [_allModel.payStatus intValue];
    int num2 = [_allModel.shippingStatus intValue];
    int num3 = [_allModel.orderStatus intValue];
    int num4 = [_allModel.commentStatus intValue];
    if (num3 == 2) {
         [self button3];
        [button3 setTitle:@"删除订单" forState:UIControlStateNormal];
         button3.tag = 1000;
        [button3 addTarget:self action:@selector(remove:) forControlEvents:UIControlEventTouchUpInside];
    }else{
        if (num1 == 0) {
            [self button3];
            [self button2];
            [button3 setTitle:@"付款" forState:UIControlStateNormal];
            [button2 setTitle:@"取消订单" forState:UIControlStateNormal];
            button2.tag = 2000;
            [button3 addTarget:self action:@selector(fuKuan) forControlEvents:UIControlEventTouchUpInside];
            [button2 addTarget:self action:@selector(quXiao:) forControlEvents:UIControlEventTouchUpInside];
        }else if(num1 ==2)
        {
    switch (num2) {
           case 0:
            [self button3];
            [button3 setTitle:@"退款申请" forState:UIControlStateNormal];
            [button3 addTarget:self action:@selector(tiXing) forControlEvents:UIControlEventTouchUpInside];
            break;
        case 1:
            [self button3];
            [self button2];
            [button3 setTitle:@"确认收货" forState:UIControlStateNormal];
            [button2 setTitle:@"查看物流" forState:UIControlStateNormal];
            [button2 addTarget:self action:@selector(wuLui) forControlEvents:UIControlEventTouchUpInside];
            [button3 addTarget:self action:@selector(queRenShouHuo) forControlEvents:UIControlEventTouchUpInside];
            break;
        case 2:
            [self button3];
            [self button2];
            if(num4 == 0){
                [button3 setTitle:@"评论" forState:UIControlStateNormal];
                [button3 addTarget:self action:@selector(pingLun) forControlEvents:UIControlEventTouchUpInside];
            }else{
            [button3 setTitle:@"已完成" forState:UIControlStateNormal];
            }
            [button2 setTitle:@"查看物流" forState:UIControlStateNormal];
            [button2 addTarget:self action:@selector(wuLui) forControlEvents:UIControlEventTouchUpInside];
            break;
        default:
           
            break;
    }
        }
    }
    return footView;
}
-(void)button1{
    button1 = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth/4, 10, KScreenWidth/4-10, 30)];
    [button1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button1.layer.cornerRadius=3;
    button1.layer.borderColor = [UIColor lightGrayColor].CGColor;
    button1.layer.borderWidth=1;
    button1.titleLabel.font = [UIFont systemFontOfSize:14];
    [_lastView addSubview:button1];
}
-(void)button2{
    button2 = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth/4*2, 10, KScreenWidth/4-10, 30)];
    [button2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button2.titleLabel.font = [UIFont systemFontOfSize:14];
    button2.layer.cornerRadius=3;
    button2.layer.borderColor = [UIColor lightGrayColor].CGColor;
    button2.layer.borderWidth=1;
    [_lastView addSubview:button2];
}
-(void)button3{
    button3 = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth/4*3, 10, KScreenWidth/4-10, 30)];
    button3.titleLabel.font = [UIFont systemFontOfSize:14];
    button3.layer.cornerRadius=3;
    button3.layer.borderColor = [UIColor redColor].CGColor;
    [button3 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    button3.layer.borderWidth=1;
    [_lastView addSubview:button3];
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 232;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 123;
   }

#pragma mark 联系商家
- (IBAction)callMaiJia:(id)sender {
    NSMutableDictionary * dic =[ [NSMutableDictionary alloc]init];
    [dic setObject:_allModel.orderId forKey:@"orderId"];//订单ID
    [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
    [NetWorking NEWjieKouQingQiu:@"联系商家" ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
        if (!error) {
            if ([dic[Code] intValue] == 200) {
                
            }
        }
    }];
}
#pragma mark 拨打电话
- (IBAction)call:(id)sender {
     NSLog(@"拨打电话");
}
#pragma mark 取消订单
-(void)quXiao:(UIButton *)button{
      int tag =(int)button.tag;
     [TCUtils showAlertViewWithTitle:@"提醒" message:@"你确定要取消订单吗?" delegate:self cancel:@"取消" other:@"确定" tag:tag];
    }
#pragma mark 删除订单
-(void)remove:(UIButton *)button{
    int tag =(int)button.tag;
    [TCUtils showAlertViewWithTitle:@"提醒" message:@"你确定要删除订单吗?" delegate:self cancel:@"取消" other:@"确定" tag:tag];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex ==1) {
        if (alertView.tag == 1000) {
            NSMutableDictionary * dic =[ [NSMutableDictionary alloc]init];
            [dic setObject:_allModel.orderId forKey:@"orderId"];//订单ID
            [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
            [NetWorking NEWjieKouQingQiu:DD_deleteOrderInfo ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
                if (!error) {
                    if ([dic[Code] intValue] == 200) {
                        [[iToast makeText:@"  成功删除订单!  "] show];
                         [[NSNotificationCenter defaultCenter]postNotificationName:@"检测状态" object:nil];
                        [self.navigationController popViewControllerAnimated:YES];
                    }
                }
            }];

        }else if(alertView.tag == 2000){
            NSMutableDictionary * dic =[ [NSMutableDictionary alloc]init];
            [dic setObject:_allModel.orderId forKey:@"orderId"];//订单ID
            [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
            [NetWorking NEWjieKouQingQiu:DD_cancelOrder ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
                if (!error) {
                    if ([dic[Code] intValue] == 200) {
                        [[iToast makeText:@"  成功取消订单!  "] show];
                         [[NSNotificationCenter defaultCenter]postNotificationName:@"检测状态" object:nil];
                        [self.navigationController popViewControllerAnimated:YES];
                    }
                }
            }];

        }
    }
}
#pragma mark 确认付款
-(void)fuKuan{
    _bigView.hidden = NO;
    [UIView animateWithDuration:0.5 animations:^{
        _viewFang.yv = KScreenHeight-130;
        _bigView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
    }];
}
-(void)drawYuEView{
    
    _tanKuang = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
    _tanKuang.alpha = 0.0;
    _tanKuang.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
    [[UIApplication sharedApplication].keyWindow addSubview:_tanKuang];
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
    [_tanKuang addGestureRecognizer:tap];
    
    _view = [[UIView alloc]initWithFrame:CGRectMake(25, KScreenHeight/2-75, KScreenWidth-50, 152)];
    _view.backgroundColor = [UIColor colorWithHue:0.00 saturation:0.00 brightness:0.93 alpha:1.00];
    [_tanKuang addSubview:_view];
    UILabel * lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth-50, 35)];
    lable.backgroundColor = [UIColor redColor];
    lable.textColor = [UIColor whiteColor];
    lable.text = @"验证登录密码!";
    lable.textAlignment = NSTextAlignmentCenter;
    lable.font = [UIFont systemFontOfSize:13];
    [_view addSubview:lable];
    _inputTextField = [[UITextField alloc]initWithFrame:CGRectMake(0, lable.bottom, KScreenWidth-50, 65)];
    _inputTextField.textAlignment = NSTextAlignmentCenter;
    _inputTextField.font = [UIFont systemFontOfSize:13];
    _inputTextField.backgroundColor = [UIColor whiteColor];
    [_view addSubview:_inputTextField];
    UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(0, _inputTextField.bottom+1, KScreenWidth-50, 50)];
    button.backgroundColor = [UIColor whiteColor];
    [button setTitle:@"确定" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:13];
    [button addTarget:self action:@selector(queMiMaEnd) forControlEvents:UIControlEventTouchUpInside];
    [_view addSubview:button];
}
-(void)tap:(UITapGestureRecognizer *)tap{
    _tanKuang.alpha = 0.0;
    _tanKuang.hidden = YES;
}

-(void)zhiFuFangShi{
    _bigView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
    _bigView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.0];
    _bigView.hidden = YES;
    [[UIApplication sharedApplication].keyWindow addSubview:_bigView];
    _viewFang = [[UIView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, 130)];
    _viewFang.backgroundColor = [UIColor whiteColor];
      NSArray *image = @[@"支付宝",@"微信支付",@"余额"];
     NSArray *title = @[@"支付宝",@"微信",@"fpl积分"];
    int width = 35*_kscW;
    int height = width;
    int zong = KScreenWidth/3;
    int zuo = (zong-width)/2;
    for (int i = 0; i<3; i++) {
        UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(zong*i+zuo, 10, width, height)];
        [button addTarget:self action:@selector(zhiFu:) forControlEvents:UIControlEventTouchUpInside];
        button.tag = i;
        [button setBackgroundImage:[UIImage imageNamed:image[i]] forState:UIControlStateNormal];
        [_viewFang addSubview:button];
        UILabel * lable = [[UILabel alloc]initWithFrame:CGRectMake(zong*i, button.bottom+5, zong, 20)];
        lable.text = title[i];
        lable.font = [UIFont systemFontOfSize:14];
        lable.textAlignment = NSTextAlignmentCenter;
        [_viewFang addSubview:lable];
        
    }
    UIButton * que = [[UIButton alloc]initWithFrame:CGRectMake(0, 90, KScreenWidth, 40)];
    que.backgroundColor =[UIColor redColor];
    [que setTitle:@"取消" forState:UIControlStateNormal];
    [que setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [que addTarget:self action:@selector(xiaoShi) forControlEvents:UIControlEventTouchUpInside];
    [_viewFang addSubview:que];
    [[UIApplication sharedApplication].keyWindow addSubview:_viewFang];
}
-(void)xiaoShi{
    _bigView.hidden = YES;
    _bigView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.0];
    [UIView animateWithDuration:0.5 animations:^{
        _viewFang.yv = KScreenHeight;
        
    }];
}
-(void)zhiFu:(UIButton *)button{
    [UIView animateWithDuration:0.5 animations:^{
        _viewFang.yv = KScreenHeight;
    }];
     _bigView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.0];
    _bigView.hidden = YES;
    if (button.tag == 0) {
        
    }else if (button.tag == 1){
        
    }else{
        [UIView animateWithDuration:0.5 animations:^{
            _tanKuang.alpha = 1.0;
            _tanKuang.hidden = NO;
            [_inputTextField becomeFirstResponder];
        }];
    }
}
-(void)queMiMaEnd{
    _tanKuang.hidden = YES;
    _tanKuang.alpha = 0.0;
    //支付接口
 
    NSMutableDictionary * dic =[ [NSMutableDictionary alloc]init];
    [dic setObject:_allModel.orderId forKey:@"orderId"];//订单ID
    [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
    [dic setObject:_inputTextField.text forKey:@"password"];
    _inputTextField.text = @"";
    [NetWorking NEWjieKouQingQiu:DD_insertOne ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
        if (!error) {
            if ([dic[Code] intValue] == 200) {
                [[iToast makeText:@"  支付成功!  "] show];
                 [[NSNotificationCenter defaultCenter]postNotificationName:@"检测状态" object:nil];
                [self.navigationController popViewControllerAnimated:YES];
            }
        }
    }];
}

#pragma mark 申请退款
-(void)tiXing{
    [_textView becomeFirstResponder];
    [UIView animateWithDuration:0.5 animations:^{
        _tanKuang2.alpha = 1.0;
    }];
//    NSMutableDictionary * dic =[ [NSMutableDictionary alloc]init];
//    [dic setObject:_allModel.orderId forKey:@"orderId"];//订单ID
//    [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
//    [NetWorking NEWjieKouQingQiu:@"提醒发货" ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
//        if (!error) {
//            if ([dic[Code] intValue] == 200) {
//                
//            }
//        }
//    }];
}
-(void)drawYuEView2{
    _tanKuang2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
    _tanKuang2.alpha = 0.0;
    _tanKuang2.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
    [[UIApplication sharedApplication].keyWindow addSubview:_tanKuang2];
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
    [_tanKuang2 addGestureRecognizer:tap];
    
    _view = [[UIView alloc]initWithFrame:CGRectMake(25, KScreenHeight/2-75, KScreenWidth-50, 152)];
    _view.backgroundColor = [UIColor whiteColor];
    [_tanKuang2 addSubview:_view];
    UILabel * lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth-50, 35)];
    lable.backgroundColor = [UIColor redColor];
    lable.textColor = [UIColor whiteColor];
    lable.text = @"请输入申请理由!";
    lable.textAlignment = NSTextAlignmentCenter;
    lable.font = [UIFont systemFontOfSize:13];
    [_view addSubview:lable];
    _textView = [[UITextView alloc]initWithFrame:CGRectMake(10, lable.bottom, KScreenWidth-70, 85)];
    _textView.font = [UIFont systemFontOfSize:13];
    _textView.backgroundColor = [UIColor whiteColor];
    [_view addSubview:_textView];
    UIView * xi = [[UIView alloc]initWithFrame:CGRectMake(0, _textView.bottom, KScreenWidth, 1)];
    xi.backgroundColor = [UIColor colorWithHue:0.00 saturation:0.00 brightness:0.87 alpha:1.00];
    [_view addSubview:xi];
    UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(0, xi.bottom, KScreenWidth-50, 30)];
    button.backgroundColor = [UIColor whiteColor];
    [button setTitle:@"确定" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:13];
    [button addTarget:self action:@selector(queMiMaEnd2) forControlEvents:UIControlEventTouchUpInside];
    [_view addSubview:button];
}
-(void)queMiMaEnd2{
    [UIView animateWithDuration:0.5 animations:^{
        _tanKuang2.alpha = 0.0;
    }];
    NSMutableDictionary * dic =[ [NSMutableDictionary alloc]init];
    [dic setObject:_allModel.orderId forKey:@"orderId"];//订单ID
    [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
    [dic setObject:_textView.text forKey:@"postscript"];//退款留言
    [dic setObject:@"1" forKey:@"backPay"];//退款方式
    [dic setObject:@"1" forKey:@"backType"];//退款类型
    [NetWorking NEWjieKouQingQiu:DD_refund ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
        NSLog(@"%@",dic[Msg]);
        if (!error) {
            if ([dic[Code] intValue] == 200) {
                [[iToast makeText:@"  申请成功!  "] show];
                 [[NSNotificationCenter defaultCenter]postNotificationName:@"检测状态" object:nil];
                [self.navigationController popViewControllerAnimated:YES];
            }
        }
    }];
}

#pragma mark 查看物流
-(void)wuLui{
    NSMutableDictionary * dic =[ [NSMutableDictionary alloc]init];
    [dic setObject:_allModel.orderId forKey:@"orderId"];//订单ID
    [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
    [NetWorking NEWjieKouQingQiu:@"查看物流" ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
        if (!error) {
            if ([dic[Code] intValue] == 200) {
                [self.navigationController popViewControllerAnimated:YES];
            }
        }
    }];
}
#pragma mark 确认收货
-(void)queRenShouHuo{
    NSMutableDictionary * dic =[ [NSMutableDictionary alloc]init];
    [dic setObject:_allModel.orderId forKey:@"orderId"];//订单ID
    [dic setObject:[self defaultLoadUserName] forKey:@"userName"];
    [NetWorking NEWjieKouQingQiu:DD_receive ANDIP:IP And:dic anBlock:^(NSDictionary *dic, NSError *error) {
        if (!error) {
            if ([dic[Code] intValue] == 200) {
                  [[iToast makeText:@"  已确认收货!  "] show];
                [[NSNotificationCenter defaultCenter]postNotificationName:@"检测状态" object:nil];
                [self.navigationController popViewControllerAnimated:YES];
            }
        }
    }];
}
#pragma mark 评论
-(void)pingLun{
    //跳转到评论页面;
    FaBiaoViewController * pingLun  = [[FaBiaoViewController alloc]init];
    pingLun.orderID =_allModel.orderId;
     pingLun.timp = 2;
    [self.navigationController pushViewController:pingLun animated:YES];

}

@end
